# -*- coding: utf-8 -*-
'''
信息系统
'''
from ...service.buss_pub.message_manage import MessageManageService


def register(jsonrpc, db_addr, db_port, db_name, db_user, db_pwd, inital_password, session):
    message_manage_func = MessageManageService(
        db_addr, db_port, db_name, db_user, db_pwd, inital_password, session)

    @jsonrpc.method('IMessageService.add_new_message')
    def __add_new_message(data):
        '''保存一条信息'''
        res = message_manage_func.add_new_message(data)
        return res

    @jsonrpc.method('IMessageService.add_new_message_type')
    def __add_new_message_type(data):
        '''保存一条信息类型'''
        res = message_manage_func.add_new_message_type(data)
        return res

    @jsonrpc.method('IMessageService.set_message_already_read')
    def __set_message_already_read(data):
        '''设置一条信息为已读'''
        res = message_manage_func.set_message_already_read(data)
        return res

    @jsonrpc.method('IMessageService.get_all_message_list')
    def __get_all_message_list(condition, page=None, count=None):
        '''获取信息列表'''
        res = message_manage_func.get_all_message_list(
            condition, page=None, count=None)
        return res

    @jsonrpc.method('IMessageService.get_unread_message_list')
    def __get_unread_message_list(condition, page=None, count=None):
        '''获取未读信息列表'''
        res = message_manage_func.get_unread_message_list(
            condition, page=None, count=None)
        return res

    @jsonrpc.method('IMessageService.get_message_type_list')
    def __get_message_type_list(condition, page=None, count=None):
        '''获取信息类型列表'''
        res = message_manage_func.get_message_type_list(
            condition, page=None, count=None)
        return res
